package arrayList2;

import java.util.*;

public class ArrayListDemo {
	public static void main(String[] args) {
		List dog = new ArrayList();
		Dog dog1 = new Dog("欧欧", "雪纳瑞");
		Dog dog2 = new Dog("菲菲", "拉布拉多");
		Dog dog3 = new Dog("敏敏", "泰迪");
		Dog dog4 = new Dog("旺财", "土狗");
		
		dog.add(dog1);
		dog.add(dog2);
		dog.add(dog3);
		dog.add(dog4);

		// 获得狗狗的总数
		System.out.println("共计有" + dog.size() + "条狗狗");
		System.out.println("分别是：");
		//逐条打印每条狗狗
		for (int i = 0; i < dog.size(); i++) {
			Dog dogs = (Dog) dog.get(i);
			System.out.println(dogs.getName() + "\t" + dogs.getStrain());
		}

		System.out.println("\n删除之前共计有" + dog.size() + "条狗狗\n");
		// 删除狗狗
		dog.remove(0);
		dog.remove(dog3);
		// 获得删除之后狗狗的总数
		System.out.println("删除之后还有" + dog.size() + "条狗狗");
		System.out.println("分别是：");
		for (int i = 0; i < dog.size(); i++) {
			Dog dogs = (Dog) dog.get(i);
			System.out.println(dogs.getName() + "\t" + dogs.getStrain());
		}
		System.out.println();
		if (dog.contains(dog2)) {
			System.out.println("集合中包含菲菲的信息");
		} else {
			System.out.println("集合中不包含菲菲的信息");
		}
	}
}
